//
//  ActivytyTableViewCell.m
//  carcar
//
//  Created by dlios on 15/9/12.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "ActivytyTableViewCell.h"
#import "BaseHeader.h"

@implementation ActivytyTableViewCell



-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(10 * suitableScreen_Width, 10 * suitableScreen_Width, 355, 40 * suitableScreen_Width)];
        [self.contentView addSubview:self.titleLabel];
        
        self.imagePhoto = [[UIImageView alloc]initWithFrame:CGRectMake(10 * suitableScreen_Width, 50 * suitableScreen_Width, 100 * suitableScreen_Width, 80 * suitableScreen_Width)];
        [self.contentView addSubview:self.imagePhoto];
        
        self.viewBrand = [[UIView alloc]initWithFrame:CGRectMake(0, 60 * suitableScreen_Width, 100 * suitableScreen_Width, 20 * suitableScreen_Width)];
        
        [self.viewBrand setBackgroundColor:[UIColor blackColor]];
        
        [self.imagePhoto addSubview:self.viewBrand];
        
        [self.viewBrand setAlpha:0.5];
        
        
        self.brandLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 60 * suitableScreen_Width, 100 * suitableScreen_Width, 20 * suitableScreen_Width)];
        [self.brandLabel setFont:[UIFont systemFontOfSize:12]];
        [self.brandLabel setTextColor:[UIColor whiteColor]];
        [self.imagePhoto addSubview:self.brandLabel];
        [self.brandLabel setTextColor:[UIColor whiteColor]];
       
        [self.brandLabel setTextAlignment:NSTextAlignmentCenter];
        self.typeLabel = [[UILabel alloc]initWithFrame:CGRectMake(120 * suitableScreen_Width, 50 * suitableScreen_Width, 100 * suitableScreen_Width, 20 * suitableScreen_Width)];
        [self.contentView addSubview:self.typeLabel];
               [self.typeLabel setTextColor:[UIColor redColor]];
        [self.typeLabel setFont:[UIFont systemFontOfSize:12]];
        self.serialLabel = [[UILabel alloc]initWithFrame:CGRectMake(120 * suitableScreen_Width, 70 * suitableScreen_Width, 220 * suitableScreen_Width , 40 * suitableScreen_Width)];
        [self.serialLabel setNumberOfLines:2];
        [self.contentView addSubview:self.serialLabel];
        
        [self.serialLabel setFont:[UIFont systemFontOfSize:12]];
        self.endLabel = [[UILabel alloc]initWithFrame:CGRectMake(120 * suitableScreen_Width , 110 * suitableScreen_Width, 200 * suitableScreen_Width, 20 * suitableScreen_Width)];
        [self.contentView addSubview:self.endLabel];

        
        [self.endLabel setFont:[UIFont systemFontOfSize:12]];
        
        self.orderLabel = [[UILabel alloc]initWithFrame:CGRectMake(275 * suitableScreen_Width, 110 * suitableScreen_Width, 100 * suitableScreen_Width, 20 * suitableScreen_Width)];
        [self.contentView addSubview:self.orderLabel];
       
        [self.orderLabel setFont:[UIFont systemFontOfSize:12]];
        [self.orderLabel setTextAlignment:NSTextAlignmentCenter];
        self.viewDi = [[UIView alloc]initWithFrame:CGRectMake(0, 150 * suitableScreen_Width , mainScreen_Width , 10 * suitableScreen_Width)];
        [self.contentView addSubview:self.viewDi];

        [self.viewDi setBackgroundColor:[UIColor colorWithRed:228/255. green:226/255. blue:233/255. alpha:1]];
        
        
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
    }
    
    
    return self ;
}

-(void)activityGetModel:(ActivityModel *)model
{
    
[self.titleLabel setText:model.title];

    [self.imagePhoto sd_setImageWithURL:[NSURL URLWithString:model.photo ]placeholderImage:[UIImage imageNamed:@"zhanweitu"]];
    
    [self.typeLabel setText:model.priceTitle];
    [self.serialLabel setText:model.serialGroupNames];
    [self.brandLabel setText:model.brandName];
    [self.endLabel setText:model.endTime];
    NSMutableAttributedString * mutableString = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"已报名%ld人",(long)model.orderCount]];
  
    NSString * order = [NSString stringWithFormat:@"%ld",(long)model.orderCount];
    
    NSInteger len = order.length ;
       [mutableString addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(3, len)];
    self.orderLabel.attributedText = mutableString ;
    
    NSString *str1 = [model.endTime substringToIndex:3];
    NSLog(@"%@",model.endTime);
    
    NSString * str2 = [model.endTime substringWithRange:NSMakeRange(5, 2)] ;
    NSString * str3 = [model.endTime substringWithRange:NSMakeRange(8, 2)];
    NSString * time = [NSString stringWithFormat:@"%@年%@月%@日截止",str1,str2,str3];
    [self.endLabel setText:time];
    
    
    
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
